package fun.anin.aninhongbao.controller;

import fun.anin.aninhongbao.dto.SendRedPacketDTO;
import fun.anin.aninhongbao.dto.SnatchRedPacketDTO;
import fun.anin.aninhongbao.result.R;
import fun.anin.aninhongbao.service.RedPacketInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 红包信息表(RedPacketInfo)表控制层
 *
 * @author makejava
 * @since 2020-03-29 14:35:57
 */
@RestController
@RequestMapping("redPacket")
public class RedPacketInfoController {
    /**
     * 服务对象
     */
    @Resource
    private RedPacketInfoService redPacketInfoService;

    /**
     * 发红包
     * @param dto
     * @return
     */
    @PostMapping("/send")
    public R sendRedPacket(SendRedPacketDTO dto){
        return redPacketInfoService.sendRedPacket(dto);
    }

    /**
     * 抢红包
     * @return
     */
    @PostMapping("/snatch")
    public R snatchRedPacket(SnatchRedPacketDTO dto){
        return redPacketInfoService.snatchRedPacket(dto);
    }

    /**
     * 拆红包
     * @return
     */
    @PostMapping("/open")
    public R openRedPacket(SnatchRedPacketDTO dto){
        return redPacketInfoService.openRedPacket(dto);
    }

    /**
     * 拆红包
     * @return
     */
    @PostMapping("/simulate")
    public R simulateOpen(Long redPacketId){
        return redPacketInfoService.simulateOpen(redPacketId);
    }
}